package com.horizon.common.util;

import com.google.gson.Gson;

import java.nio.charset.StandardCharsets;

/**
 * @author zhaoshb
 * @since 2023/1/13 09:01
 */
public class GsonUtil {

    private static final Gson gson = new Gson();

    public static <T> T fromJson(String content, Class<T> type) {
        return gson.fromJson(content, type);
    }

    public static <T> String toJson(T src) {
        return gson.toJson(src);
    }

    public static <T> byte[] toJsonBytes(T src) {
        return gson.toJson(src).getBytes(StandardCharsets.UTF_8);
    }
}



